//
//  ClassCollectionViewCell.m
//  Cartoon
//
//  Created by dllo on 15/10/29.
//  Copyright © 2015年 YSZ. All rights reserved.
//

#import "ClassCollectionViewCell.h"
#import "Classification.h"
@implementation ClassCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    
    self = [super initWithFrame:frame];
    if (self) {
        
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_nameLabel];
        
        _photoImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_photoImageView];
        _photoImageView.layer.cornerRadius = 50;
        _photoImageView.clipsToBounds = YES;
        
        
    }
    return self;
    
}

+ (instancetype)classifyCellWithCollectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{

    ClassCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Classify_Cell" forIndexPath:indexPath];
    
    return cell;
}


- (void)setClassifyModel:(Classification *)classifyModel
{

    _classifyModel = classifyModel;
    // 把模型中的数据设置给单元格的子控件
    if ([classifyModel.classify_title isEqualToString:@"VIP"]) {
        self.nameLabel.text = @"喜欢";
    }else{
        self.nameLabel.text = classifyModel.classify_title;
    }

    [self.photoImageView sd_setImageWithURL:[NSURL URLWithString:classifyModel.classify_url]placeholderImage:[UIImage imageNamed:@"5"]];
    
}


- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    
    _photoImageView.frame = CGRectMake(0, 0, 100, 100);
    
    _nameLabel.frame = CGRectMake(0, 100, 100, 30);
    
}


@end
